<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddColumnParamInCosMediaTable extends AbstractMigration
{
    public function up()
    {
        $this->table('cos_media')
            ->addColumn('param', 'json', ['null' => true, 'comment' => 'mediaData存储'])
            ->addColumn('request_url', 'string', ['default' => '', 'limit' => 255, 'comment' => '前缀请求地址'])
            ->changeColumn('cos_key', 'string', ['default' => '', 'limit' => 255, 'comment' => '存储key'])
            ->addIndex(['request_url', 'cos_key',], ['type' => 'normal', 'name' => 'idx_request_url_cos_key'])
            ->save();
    }

    public function down()
    {
        $this->table('cos_media')
            ->removeColumn('param')
            ->removeColumn('request_url')
            ->removeIndex("idx_request_url_cos_key")
            ->save();
    }
}
